package chat;

//================== UserInfo.java ==================
import java.io.ObjectOutputStream;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

class UserInfo {
    private String username;
    private ObjectOutputStream output;
    private Set<String> groups;
    private Set<String> openWindows;
    private String ipAddress;
    private int voicePort = -1;
    private String lastLogoutTime; // 新增字段

    // 新增 getter/setter
    public String getLastLogoutTime() {
        return lastLogoutTime;
    }

    public void setLastLogoutTime(String lastLogoutTime) {
        this.lastLogoutTime = lastLogoutTime;
    }

    // 添加getter和setter
    public int getVoicePort() {
        return voicePort;
    }

    public void setVoicePort(int voicePort) {
        if (voicePort > 0 && voicePort <= 65535) {
            this.voicePort = voicePort;
        }
    }

    public UserInfo(String username, ObjectOutputStream output) {
        this.username = username;
        this.output = output;
        this.groups = ConcurrentHashMap.newKeySet();
        this.openWindows = ConcurrentHashMap.newKeySet();
    }

    // Getters and Setters
    public String getUsername() { return username; }
    public ObjectOutputStream getOutput() { return output; }
    public Set<String> getGroups() { return groups; }
    public Set<String> getOpenWindows() { return openWindows; }
    public void setOutput(ObjectOutputStream output) { this.output = output; }
    public String getIpAddress() { return ipAddress; }
    public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
}